home *** CD-ROM | disk | FTP | other *** search
-
-
-
- const
- HT = chr(9);
- CR = chr(13);
- SPACES = [' ', HT, CR];
-
- procedure val
- (s : string; var v : integer; var code : integer);
- var
- c : char;
- digit, i, n : integer;
- neg : boolean;
-
- function next : char;
- begin
- if i < length(s) then
- begin
- inc(i);
- next := s[i];
- end
- else
- next := chr(0);
- end;
-
- begin
- i := 0;
- c := next;
- while c in SPACES do
- c := next;
- neg := FALSE;
- if c = '+' then
- c := next
- else if c = '-' then
- begin
- neg := TRUE;
- c := next;
- end;
- if not (c in ['0' .. '9']) then
- begin
- code := i;
- exit;
- end;
- n := 0;
- while c in ['0' .. '9'] do
- begin
- n := n * 10 + ord(c) - ord('0');
- c := next;
- end;
- if neg then
- n := -n;
- v := n;
- if c = chr(0) then
- code := 0
- else
- code := i;
- end;
-
- ----------
-
-